package com.vogue.api.controller;

import com.alibaba.fastjson.JSONObject;
import com.vogue.api.common.rsa.annotation.Decrypt;
import com.vogue.api.common.rsa.annotation.Encrypt;
import com.vogue.api.common.rsa.annotation.DecryptAndEncrypt;
import com.vogue.api.data.UserVo;
import com.vogue.api.data.ResultVo;
import com.vogue.api.service.CateringUserService;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户记录表
 * @author George<qiaozhi_china@163.com>
 */
@Api(tags = "用户记录表")
@RestController
@RequestMapping("/api")
public class JsEncryptController {

	protected Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	private CateringUserService cateringUserService;


	/**
	 * 加密
	 * @param user
	 * @return
	 */
	@Encrypt
	@Decrypt
	@PostMapping("/encryption")
	public ResultVo<?> encryption(@RequestBody UserVo user){
		logger.info(JSONObject.toJSONString(user));
		return ResultVo.success(user);
	}

	/**
	 * 解密
	 * @param user
	 * @return
	 */
	@DecryptAndEncrypt
	@PostMapping("/decryption")
	public ResultVo<?> Decryption(@RequestBody UserVo user){
		logger.info(JSONObject.toJSONString(user));
		return ResultVo.success(user);
	}

}
